package cn.signalpha.modules.shop.entity;

import cn.signalpha.core.swagger.ApiModelPropertyEnum;
import cn.signalpha.core.tool.utils.DateUtil;
import cn.signalpha.modules.shop.entity.enums.CouponUseTypeEnum;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

/**
 * 实体类
 *
 * @author signalpha
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("shop_coupon")
@ApiModel(value = "Coupon对象", description = "优惠券")
public class Coupon implements Serializable {

    private static final long serialVersionUID = 1L;

	@TableId(value = "id", type = IdType.ASSIGN_ID)
	@JsonSerialize(using = ToStringSerializer.class)
	private Long id;

	@ApiModelProperty(value = "商户id")
    private Long sellerId;

    @ApiModelProperty(value = "优惠券名称")
    private String name;

	@ApiModelProperty(value = "优惠券简介")
	private String brief;

    @ApiModelProperty(value = "优惠券金额")
    private Double money;

    @ApiModelProperty(value = "优惠券类型 1手动领取 2赠送券")
    private Integer type;

//    @ApiModelProperty(value = "是否限量")
//    private Integer isLimited;

    @ApiModelProperty(value = "发放总数")
    private Integer total;

    @ApiModelProperty(value = "剩余数量")
    private Integer lastTotal;

	@ApiModelProperty(value = "每人限领")
    private Integer limitNum;

    @ApiModelProperty(value = "使用类型")
	@ApiModelPropertyEnum(CouponUseTypeEnum.class)
    private Integer useType;

    @ApiModelProperty(value = "所属商品id，分类id")
    private String primaryKey;

    @ApiModelProperty(value = "最低消费，0代表不限制")
    private Double minPrice;

    @ApiModelProperty(value = "是否固定使用时间")
    private Integer isFixedTime;

    @ApiModelProperty(value = "天数")
    private Integer day;

	@DateTimeFormat(pattern = DateUtil.PATTERN_DATE)
	@JsonFormat(pattern = DateUtil.PATTERN_DATE)
    @ApiModelProperty(value = "可使用开始时间")
    private Date useStartTime;

	@DateTimeFormat(pattern = DateUtil.PATTERN_DATE)
	@JsonFormat(pattern = DateUtil.PATTERN_DATE)
    @ApiModelProperty(value = "可使用结束时间")
    private Date useEndTime;

    @ApiModelProperty(value = "排序值")
    private Integer sort;

    @ApiModelProperty(value = "状态：0关闭 1开启")
    private Integer status;

    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @ApiModelProperty(value = "更新时间")
    private Date updateTime;

}
